package database

import (
	"dingbot/config"
	"dingbot/errhelp"
	"os"
	"os/exec"
	"runtime"
)

func Run() {
	run_system := runtime.GOOS
	var run_exec_name string = "./pocketbase"
	if run_system == "windows" {
		// windows
		run_exec_name += ".exe"
	}
	run_exec := exec.Command(run_exec_name, "serve", "--http=127.0.0.1:"+config.GetConfig().Port.PocketBase)
	run_exec.Stdin = os.Stdin
	run_exec.Stdout = os.Stdout
	run_exec.Stderr = os.Stderr
	err := run_exec.Start()
	errhelp.Abort(err, "启动pocketbase数据库失败！")
}
